package view
{
	import ui.GameStartUI;
	import laya.events.Event;
	import laya.utils.Handler;
	/**
	 * ...
	 * @author
	 */
	public class GameStart extends GameStartUI{
		public function GameStart(){
			this.on(Event.ADDED,this,onAddToStage);
			this.on(Event.REMOVED,this,onRemoveFromStage);
		}

		private function onAddToStage():void
		{
			btn_start.on(Event.CLICK,this,onClickStart);
		}

		private function onRemoveFromStage():void
		{
			btn_start.off(Event.CLICK,this,onClickStart);
		}

		private function onClickStart():void
		{
			Laya.loader.load(ResPath.GAME_ROLE,Handler.create(this,this.loadComplete),Handler.create(this,this.loadProgress));
		}

		private function loadComplete():void
		{
			GameDispatcher.getInstance().event(EventName.GAME_START);
		}

		private function loadProgress(loadNum:Number):void
		{
			this.txt_load.text="资源加载中："+parseInt(loadNum*100)+"%";
		}
	}

}